<template>
<div>
    <!--科室-->
    <el-row style="width: 80%;margin: 50px auto;">
        <el-card style="width: 48%;margin-right:10px;margin-bottom:30px;min-height: 300px;display: inline-block"
                 v-for="(itemList, index) in depList" :key="index">
            <h1 style="margin-left: 30px">{{itemList.title}}</h1>
            <el-button class="box-card" type="success" plain
                     style="width: 150px;margin:0 20px 20px 30px;
                     display: inline-block;cursor: pointer;text-align: center"
                       v-for="item in itemList.items" :key="item.id" @click="selectDep(item.id)">{{item.depTitle}}
            </el-button>

        </el-card>
    </el-row>
</div>
</template>
<style>
body{
    margin: 0 auto;
    background-image: none;
}
</style>

<script>
import BaseUrl from "@/http/BaseUrl";
import SimpleAxios from "@/http/SimpleAxios";
import TokenAxios from "@/http/TokenAxios";

export default {
    data(){
        return{
            department:[],
            loginInfo:[],
            depList: [
                {title:'常见科室',items: []},
                {title:'内科',items: []},
                {title:'外科',items: []},
                {title:'其他',items: []}
            ]

        }
    },
    methods: {
/*        loadDepartments(){
            let depUrl=BaseUrl.INDEX+`/encyclopedia/encList/departments/${}`;

            SimpleAxios.get(depUrl).then((response)=>{
                let jsonResult=response.data;
                if (jsonResult.state===20000){
                    this.department=response.data.data;
                }
            })
        },*/
        loadDepartmentType(depType) {
            let url =BaseUrl.CHAT+ `/chat/depList/${depType}`;
            TokenAxios.get(url).then(response => {
                this.depList[depType - 1].items = response.data.data;
            })
        },
        selectDep(key,keyPath){
            let chatUrl;
            chatUrl = '/consult/chat?depId=' + key;
            console.log(chatUrl);
            // this.$router.push(chatUrl);
            location.href=chatUrl;
        },
        loadCurrentLoginInfo(){
            this.loginInfo=JSON.parse(localStorage.getItem('loginInfo'));
        }
    },
    created() {
        // this.loadDepartments();
        this.loadDepartmentType(1)
        this.loadDepartmentType(2)
        this.loadDepartmentType(3)
        this.loadDepartmentType(4)

    },
    mounted() {
        this.loadCurrentLoginInfo();
    }
}
</script>